﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Epic.TakeHome.Al {

  class Product {
    private CalculateShippingCost _calculateShippingCost;
    private CalculateRetailCost _calculateRetailCost;

    public Product(string name, double weight, double wholeSalePrice, InvSystem system) {
      Name = name;
      Weight = weight;
      WholeSalePrice = wholeSalePrice;

      _calculateShippingCost = system.calculateShipping;
      _calculateRetailCost = system.calculateRetail;
      init();
    }

    private void init() {
      if (Weight < 0) { Weight = 0.0; }
      if (WholeSalePrice < 0) { WholeSalePrice = 0.0; }
    }

    public string Name {  get; protected set; }
    public double Weight { get; protected set; }
    public double WholeSalePrice { get; protected set; }
    public int Quantity { get; set; }

    public double ShippingCost {
      get {
        return _calculateShippingCost (this);
      }
    }
    
    public double RetailCost {
      get {
        return _calculateRetailCost(this);
      }
    }

  }

  delegate double CalculateShippingCost(Product p);
  delegate double CalculateRetailCost(Product p);

}
